const express = require('express')
const router = express.Router()
const birdsDao = require('../database/birdsDao')
// 根据鸟类图鉴id获取鸟类图鉴
router.get('/getBirdsByID', async (req, res) => {
  let id = req.query.id
  console.log(id)
  try {
    let result = await birdsDao.getBirds(id)
    res.send({
      code: 200,
      msg: '获取成功',
      data: result
    })
  } catch (err) {
    res.send({
      code: 400,
      msg: '获取失败',
      data: err
    })
  }
})
// 获取全部鸟类图鉴
router.get('/getAllBirds', async (req, res) => {
  try {
    let result = await birdsDao.getAllBirds()
    res.send({
      code: 200,
      msg: '获取成功',
      data: result
    })
  } catch (err) {
    res.send({
      code: 400,
      msg: '获取失败',
      data: err
    })
  }
})

module.exports = router